package it.polimi.swimv2.entities;

import it.polimi.swimv2.util.StringCapitalizer;

import java.io.Serializable;
import java.lang.String;
import javax.persistence.*;

/**
 * Entity implementation class for Entity: Ability
 * Ability represents a declarable ability for swimv2 users.
 */
@Entity
@Table(name = "Ability")
public class Ability implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "name", nullable = false)
	private String name;
	
	/**
	 * Default constructor.
	 */
	public Ability() {
		super();
	}

	/**
	 * 
	 * @param abilityName 
	 */
	public Ability(String abilityName) {
		super();
		setName(abilityName);
	}

	/**
	 * 
	 * @return the name of the ability
	 */
	public String getName() {
		return this.name;
	}

	private void setName(String abilityName) {
		this.name = StringCapitalizer.capitalize(abilityName);
	}

	/**
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	/**
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Ability))
			return false;
		Ability other = (Ability) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "Ability [name=" + name + "]";
	}

}
